﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<JLL.China.Infrastructure.Repositories.LINQ2SQL.Country>" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <link href="<%=Url.Content("~/Scripts/qtip2/jquery.qtip.min.css") %>" rel="stylesheet"
        type="text/css" />
    <link href="<%=Url.Content("~/Scripts/jquery.validation/validationEngine.jquery.css")%>"
        rel="stylesheet" type="text/css" />
    <link href="<%=Url.Content("~/Scripts/chosen/chosen.css")%>" rel="stylesheet" type="text/css" />
    <link href="<%=Url.Content("~/Content/css/mod-listing.css")%>" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .scrollbox
        {
            height: auto;
            min-width: 580px !important;
            line-height: 18px;
        }
        body
        {
            font: 12px Arial;
        }
        
    </style>

    <script src="<%=Url.Content("~/Scripts/jquery-1.7.2.js")%>" type="text/javascript"></script>

    <!-- -->

    <script src="<%=Url.Content("~/Scripts/jquery.validation/jquery.validationEngine-en.js")%>"
        type="text/javascript"></script>

    <script src="<%=Url.Content("~/Scripts/jquery.validation/jquery.validationEngine.js")%>"
        type="text/javascript"></script>

    <script src="<%=Url.Content("~/Scripts/chosen/chosen.jquery.min.js")%>" type="text/javascript"></script>

    <script src="<%=Url.Content("~/Scripts/knockout/knockout.js")%>" type="text/javascript"></script>

    <script src="<%=Url.Content("~/Scripts/knockout/knockout.mapping.js")%>" type="text/javascript"></script>

    <script src="<%=Url.Content("~/Scripts/Utility.js")%>" type="text/javascript"></script>

    <script>

        var BASE_URL ='<%=Url.Content("~/")%>';
            $(document).ready(function() {
                    $("#formID").validationEngine({
                    prettySelect: true,
                    useSuffix: "_chzn",
                    promptPosition: "topLeft", 
                    scroll: false
                        });
                //
                  
        
        $.ajaxSetup({ cache: false });
            $("#country_en").bind("keyup change blur", function() {
                var data = $(this).val();
             
                if (data.length == 0) {
                    $("#checkitem1").text("");
                    $("#checkitem1").removeClass("green");
                    $("#checkitem1").removeClass("red");
                } else {
                    $.ajax({
                        url: BASE_URL + "Listings/Country/CheckNameEN",
                        type: 'POST', // POST or GET
                        data: { name: data},
                        success: function(result, status) {
                            if (result == "YES") {
                                $("#checkitem1").text("That name  is already in use.");
                                $("#checkitem1").removeClass("green");
                                $("#checkitem1").addClass("red");

                            } else {
                                $("#checkitem1").text("");
                                $("#checkitem1").removeClass("red");
                                // $(".checkitem").addClass("green");

                            }
                        }
                    }
		);

                }
            });
                //
                  $("#country_cn").bind("keyup change blur", function() {
                var data = $(this).val();
               
                if (data.length == 0) {
                    $("#checkitem2").text("");
                    $("#checkitem2").removeClass("green");
                    $("#checkitem2").removeClass("red");
                } else {
                    $.ajax({
                        url: BASE_URL + "Listings/Country/CheckNameCN",
                        type: 'POST', // POST or GET
                        data: { name: data },
                        success: function(result, status) {
                            if (result == "YES") {
                                $("#checkitem2").text("That name  is already in use.");
                                $("#checkitem2").removeClass("green");
                                $("#checkitem2").addClass("red");

                            } else {
                                $("#checkitem2").text("");
                                $("#checkitem2").removeClass("red");
                                // $(".checkitem").addClass("green");

                            }
                        }
                    }
		);

                }
            });
                
            });


        <% if(ViewData["SaveAction"]!=null)
           {%>
        window.parent.location.href = window.parent.location.href;
        <% } %>
      
             
          
    </script>

    <title>Edit</title>
</head>
<body>
    <% using (Html.BeginForm("Update", "Country", FormMethod.Post, new { id = "formID", enctype = "multipart/form-data", @class = "validateform" }))
       { %>
    <%= Html.HiddenFor(x => x.Country_ID) %>
    <% if (Model.Country_ID != 0)
       { %>
    <p>
        <h3 style="margin-left: 8px">
            Update Country Name
        </h3>
    </p>
    <% }
       else
       { %>
    <p>
        <h3 style="margin-left: 8px">
            Insert Country Name
        </h3>
    </p>
    <% } %>
    <table align="center" cellpadding="10" cellspacing="10" class="style1" style="padding: 5px"
        width="">
        <tr>
            <td style="width: 30%">
                <font color="red">(*)</font>Country name( Enlish)
            </td>
            <td style="width: 50%">
                <%= Html.TextBoxFor(x => x.Country_EN,
                                               new
                                                   {
                                                       name = "country_en",
                                                       id = "country_en",
                                                       @class = "validate[required] inp-form",
                                                       style = "width: 100%"
                                                   }) %>
                <a class="checkitem" id="checkitem1"></a>
            </td>
        </tr>
        <tr>
            <td style="width: 30%">
                <font color="red">(*)</font>Country name( Local)
            </td>
            <td style="width: 50%">
                <%= Html.TextBoxFor(x => x.Country_CN,
                                               new
                                                   {
                                                       name = "country_cn",
                                                       id = "country_cn",
                                                       @class = "validate[required] inp-form",
                                                       style = "width: 100%"
                                                   }) %>
                <a class="checkitem" id="checkitem2"></a>
            </td>
        </tr>
        <tr>
            <td style="width: 30%">
                <font color="red">(*)</font>Active
            </td>
            <td style="width: 50%">
                <%=Html.DropDownListFor(m => m.IsActive, new List<SelectListItem>
                     {
                        new SelectListItem{Selected = true, Text="Active", Value = "1" }, 
                        new SelectListItem{Selected = false, Text="Inactive", Value = "0" },
                     }, new { id = "country_status", name = "country_status", @class = "chzn-nosearch chz" })%>
            </td>
        </tr>
        <tr>
            <td>
            </td>
            <td width="20%" align="right">
                <input type="button" value="Cancel" class="buttons" style="margin-right: 18px; float: right;
                    cursor: pointer" onclick="window.parent.location='<%= Url.Content("~/Listings/Country/Index") %>'" />
                <input type="submit" value="Save" class="buttons" style="margin-right: 8px; float: right" />
            </td>
        </tr>
    </table>
    <% } %>
</body>
</html>
